const nodemailer = require("nodemailer")
// 创建 SMTP 客户端
const transporter = nodemailer.createTransport({
  service: "qq",
  auth: {
    user: "2625324637@qq.com",
    pass: "qqmksspazsfoebhh",
  },
})
exports.create = (router) => {
  router.post("/sendEmail/post", (req, res) => {
    const { to, subject, body } = req.body
    const mailOptions = {
      from: "2625324637@qq.com",
      to,
      subject,
      text: body,
    }
    // 发送邮件
    transporter.sendMail(mailOptions, (error, info) => {
      if (error) {
        res.status(500).send({message:false})
      } else {
        res.send({message:true})
      }
    })
  })
}
